Esempio n. 1
0
 /**
  * Generate a Perspective from a legacy ToolbarAction
  * 
  * @param \SimpleXMLElement $node
  * @param $extensionId
  * @return static
  */
 public static function fromLegacyToolbarAction(\SimpleXMLElement $node, $extensionId)
 {
     $data = array('id' => (string) $node['id'], 'extension' => $extensionId, 'name' => (string) $node['title'], 'level' => (int) $node['level'], 'description' => empty($text) ? null : $text, 'binding' => isset($node['binding']) ? (string) $node['binding'] : (isset($node['js']) ? (string) $node['js'] : null), 'structure' => isset($node['structure']) ? (string) $node['structure'] : null, 'group' => self::GROUP_SETTINGS, 'icon' => isset($node['icon']) ? Icon::fromArray(array('id' => (string) $node['icon']), $extensionId) : null);
     $children = array();
     if (isset($node['structure'])) {
         $children = array();
         // (string)$node['structure']
     }
     return new static($data, $children);
 }
Esempio n. 2
0
 /**
  * Try to get the action's icon the old way. 
  * I/O impact (file_exists) is limited as the results can be serialized.
  *
  * @return Icon the icon with the src property set to the icon URL.
  */
 private function inferLegacyIcon()
 {
     $ext = $this->getExtensionId();
     $name = strtolower(\tao_helpers_Display::textCleaner($this->data['name']));
     $file = $ext . '/views/img/actions/' . $name . '.png';
     $src = 'actions/' . $name . '.png';
     if (file_exists(ROOT_PATH . $file)) {
         return Icon::fromArray(array('src' => $src), $ext);
     } else {
         if (file_exists(ROOT_PATH . 'tao/views/img/actions/' . $name . '.png')) {
             return Icon::fromArray(array('src' => $src), 'tao');
         } else {
             return Icon::fromArray(array('src' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAAAnRSTlMA/1uRIrUAAAAKSURBVHjaY/gPAAEBAQAcsIyZAAAAAElFTkSuQmCC'), 'tao');
         }
     }
 }